#include"lottery_sys.h" 
Lottery_t* load_lott(void)
{
//	printf("发布彩票1\n");
	FILE* fpi = NULL;
	Lottery_t* lott_head = NULL;
	Lottery_t* tail = NULL;
	Lottery_t* cur = NULL;
	int ret = 0;
	lott_head = init_lott_list();
	tail = lott_head;
	cur = (Lottery_t*)calloc(1,sizeof(Lottery_t));
	if(!cur)
	{
		return NULL;
	}
	fpi = fopen(LOTTERY_FILE,"rb");
	if(!fpi)
	{
	    printf("彩票文件加载失败！\n");
		free(cur);
		return lott_head;
	}
	while(1)
	{
		ret = fread(cur,sizeof(Lottery_t),1,fpi);
		if(ret < 1)
		{
			break;
		}
		tail -> next = cur;
		tail = cur;
		cur = (Lottery_t*)calloc(1,sizeof(Lottery_t));
		if(!cur)
		{
			return NULL;
		}
	}
	tail -> next = NULL;
	free(cur);
	fclose(fpi);
//	show_lott_list(lott_head);
	return lott_head;
}

